﻿using AutoMapper;
using J.Status.Application.Command.LodgingCommand;
using J.StatusModel;
using J.StatusModel.Dto;
using MediatR;
using StatusDto;
using StatusService;

namespace J.Status.Application.Handler.LodgingHandler
{
    public class LodgingSelectHandler:IRequestHandler<LodgingSelectCommand,PageDto<LodgingDto>>
    {
        private readonly ILodgingDtoService lodgingDtoService;
        private readonly IMapper mapper;
        public LodgingSelectHandler(ILodgingDtoService lodgingDtoService, IMapper mapper)
        {
            this.lodgingDtoService = lodgingDtoService;
            this.mapper = mapper;
        }

        public async Task<PageDto<LodgingDto>> Handle(LodgingSelectCommand request, CancellationToken cancellationToken)
        {
            LodgingFindDto model = mapper.Map<LodgingFindDto>(request);
            return await lodgingDtoService.LodgingList(model);
        }
    }
}
